<!--#Include File="../conn.asp" -->
<!--#Include File="comm/inc.asp" -->
<%
'====================================================================
'= Team Elite - Elite Article System
'= Copyright (c) 2005 - 2006 Eason Chan All Rights Reserved.
'=-------------------------------------------------------------------
'= 版权协议：
'=	GPL (The GNU GENERAL PUBLIC LICENSE Version 2, June 1991)
'=-------------------------------------------------------------------
'= 文件名称：/Manager/Admin_InsideLink.asp
'= 摘    要：后台-站内连接管理文件
'=-------------------------------------------------------------------
'= 最后更新：eason007
'= 最后日期：2005-12-21
'====================================================================

Call EA_Manager.Chk_IsMaster

If Not EA_Manager.Chk_Power(Admin_Power,"05") Then 
	ErrMsg=str_Comm_NotAccess
	Call EA_Manager.Error(1)
End If

Dim Atcion
Atcion=Request.QueryString ("atcion")

Select Case LCase(Atcion)
Case "save"
	Call Save
Case "del"
	Call del
Case "add"
	Call Add
Case Else
	Call Main
End Select
Call EA_Pub.Close_Obj
Set EA_Pub=Nothing

Sub Main
	Dim Count,PageCount,Page,OutStr,i
	Dim FieldName(0),FieldValue(0)
	Dim WStr,TopicList
	Dim Temp,ListBlock
	
	Page=EA_Pub.SafeRequest(3,"page",0,1,0)

	PageContent=Template.LoadTemplate("admin_insidelink_list.htm")


	Template.SetVariable "Language_Comm_ListEmpty",str_Comm_ListEmpty,PageContent
	Template.SetVariable "Language_Comm_Bar_Operation",str_Comm_Bar_Operation,PageContent
	Template.SetVariable "Language_Comm_Edit_Operation",str_Comm_Edit_Operation,PageContent
	Template.SetVariable "Language_Comm_Alert_Del_Operation",str_Comm_Alert_Del_Operation,PageContent
	Template.SetVariable "Language_Comm_Del_Operation",str_Comm_Del_Operation,PageContent

	Template.SetVariable "Language_OperationNotice",str_OperationNotice,PageContent
	Template.SetVariable "Language_InsideLink_Help",str_InsideLink_Help,PageContent

	Template.SetVariable "Language_InsideLink_InsideLinkList",str_InsideLink_InsideLinkList,PageContent
	Template.SetVariable "Language_InsideLink_AddInsideLink",str_InsideLink_AddInsideLink,PageContent
	Template.SetVariable "Language_InsideLink_LinkWord",str_InsideLink_LinkWord,PageContent
	Template.SetVariable "Language_InsideLink_LinkURL",str_InsideLink_LinkURL,PageContent
	Template.SetVariable "Language_InsideLink_Location",str_InsideLink_Location,PageContent


	ListBlock=Template.GetBlock("list",PageContent)

	Count=EA_M_DBO.Get_InsideLink_Total()(0,0)
	If Count>0 Then 
		Template.SetVariable "ListTempty","none",PageContent

		TopicList=EA_M_DBO.Get_InsideLink_List(Page,15)
	
	    For i=0 To Ubound(TopicList,2)
			Temp=ListBlock
  
			Template.SetVariable "LinkID",TopicList(0,i),Temp
			Template.SetVariable "LinkWord",TopicList(1,i),Temp
			Template.SetVariable "LinkURL",TopicList(2,i),Temp
			Template.SetVariable "LinkLocation",TopicList(3,i),Temp

			Template.SetBlock "list",Temp,PageContent
		Next

		Template.SetVariable "PageListNav",EA_Manager.PageList(15,Count,Page,FieldName,FieldValue),PageContent
	End If
	Template.CloseBlock "list",PageContent


	Template.BaseReplace PageContent
	Template.OutStr PageContent
End Sub

Sub Add
	Dim PostId,Level,Temp,i,ColumnList
	Dim Word,Link,ColumnId
	PostId=EA_Pub.SafeRequest(3,"postid",0,0,0)

	Temp=EA_M_DBO.Get_InsideLink_Info(PostId)
	If IsArray(Temp) Then 
		Word=Temp(0,0)
		Link=Temp(1,0)
		ColumnId=Temp(2,0)
	End If

	Temp=EA_DBO.Get_Column_List()
	If IsArray(Temp) Then
		For i=0 To UBound(Temp,2)
			Level=(Len(Temp(2,i))/4-1)*3
			ColumnList = ColumnList & "<option value="""&Temp(0,i)&""""
			If ColumnId<>"" Then 
				If Cint(ColumnId)=Cint(Temp(0,i)) Then ColumnList = ColumnList & " selected"
			End If
			ColumnList = ColumnList & ">"
			ColumnList = ColumnList & "├"
			ColumnList = ColumnList & String(Level,"-")
			ColumnList = ColumnList & Temp(1,i)&"</option>"
		Next
	End If

	PageContent=Template.LoadTemplate("admin_insidelink_option.htm")


	Template.SetVariable "Language_Comm_Save_Button",str_Comm_Save_Button,PageContent
	Template.SetVariable "Language_Comm_Reset_Button",str_Comm_Reset_Button,PageContent

	Template.SetVariable "Language_OperationNotice",str_OperationNotice,PageContent
	Template.SetVariable "Language_InsideLink_Help",str_InsideLink_Help,PageContent

	Template.SetVariable "Language_InsideLink_InsideLinkList",str_InsideLink_InsideLinkList,PageContent
	Template.SetVariable "Language_InsideLink_AddInsideLink",str_InsideLink_AddInsideLink,PageContent
	Template.SetVariable "Language_InsideLink_Input_Info",str_InsideLink_Input_Info,PageContent
	Template.SetVariable "Language_InsideLink_LinkWord",str_InsideLink_LinkWord,PageContent
	Template.SetVariable "Language_InsideLink_LinkURL",str_InsideLink_LinkURL,PageContent
	Template.SetVariable "Language_InsideLink_Location",str_InsideLink_Location,PageContent

	Template.SetVariable "ColumnList",ColumnList,PageContent

	Template.SetVariable "LinkID",PostId,PageContent
	Template.SetVariable "Word",Word,PageContent
	Template.SetVariable "Link",Link,PageContent


	Template.BaseReplace PageContent
	Template.OutStr PageContent
End Sub

Sub Save
	Call EA_Pub.Chk_Post
	
	Dim Word,Link,ColumnId
	Dim PostId
	PostId=EA_Pub.SafeRequest(3,"postid",0,0,0)
	Word=EA_Pub.SafeRequest(2,"word",1,"",1)
	Link=EA_Pub.SafeRequest(2,"link",1,"",1)
	ColumnId=EA_Pub.SafeRequest(2,"column",0,0,0)

	If Rs.State=1 Then rs.Close
	If PostId<>0 Then
		Sql="Select * From [NB_Link] Where [Id]="&PostId
		rs.Open Sql,Conn,2,2
	Else
		rs.Open "NB_Link",Conn,2,2
		rs.AddNew
	End If
		rs("Word")=Word
		rs("Link")=Link
		rs("ColumnId")=ColumnId
		rs.update
	Rs.Close:Set Rs=Nothing
	
	Set Rs=Nothing
	Call EA_Pub.Close_Obj
	Set EA_Pub=Nothing
	
	Response.Redirect "admin_insidelink.asp"
End Sub

Sub Del
	Call EA_Pub.Chk_Post
	
	Dim PostId
	PostId=EA_Pub.SafeRequest(3,"postid",0,0,0)

	EA_M_DBO.Set_InsideLink_Delete PostId
	
	Call EA_Pub.Close_Obj
	Set EA_Pub=Nothing
	
	Response.Redirect Request.ServerVariables("HTTP_REFERER")
End Sub
%>